package org.colin.controller;


import io.swagger.annotations.*;
import org.colin.aop.annotation.LogAnnotation;
import org.colin.code.BaseResponseCode;
import org.colin.service.SysAppUserService;
import org.colin.utils.DataResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * APP 注册用户管理
 * </p>
 *
 * @author LiRuiFeng
 * @since 2021-01-09
 */
@Controller
@Api(tags = "基础数据管理-APP注册用户管理")
@RequestMapping("/report")
public class DUserController {

    @Autowired
    SysAppUserService sysAppUserService;


    @ApiOperation(value = "近期数据一览")
    @LogAnnotation(title = "基础数据管理", action = "近期数据一览")
    @GetMapping("getStatisticsByCount")
    @ResponseBody
    public DataResult getStatisticsByCount(){
        HashMap map = sysAppUserService.getStatistics();
        DataResult success = DataResult.success();
        success.setData(map);
        return success;
    }


    @ApiOperation(value = "历史数据")
    @LogAnnotation(title = "基础数据管理", action = "历史数据")
    @GetMapping("getStatisticsByHistoryAndMonth")
    @ResponseBody
    @ApiImplicitParams({
            @ApiImplicitParam(name = "year" ,value = "年份", paramType = "query"),
    })
    public DataResult getStatisticsByHisAndMonth(Integer year){
        if(year == null || year <= 0){
            return new DataResult(BaseResponseCode.OPERATION_ERROR.getCode(),   "查询失败,历史年份不能为空");
        }
        Map map = sysAppUserService.getStatisticsByHisAndMonth(year);
        DataResult success = DataResult.success();
        success.setData(map);
        return success;
    }




}
